package tsing.javase.util;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author Tsing/吴清平
 * @Date 2022/12/13 16:32
 * @Version 1.0
 */
public class TimeUtil {

    /**
     * 获取当前时间，精确稻苗
     * @return
     */

    public static String getCurrentTime(){
        Date currentTime = new Date();
        DateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
        return formatter.format(currentTime);
    }


    /**
     * 获取当月最后一天最后一秒
     */

    public static String getDateLocalMouthFinalDay() {

        int mouth =  Integer.parseInt(new SimpleDateFormat("MM").format(new Date())) ; //当月
        StringBuilder sb = new StringBuilder();
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
        sb.append(sdf.format(date));
        int[]  array =  {1,3,5,7,8,10,12};

        boolean  flag = false;
        for (int array1 : array) {
            if(array1 ==mouth){
                flag = true;
                break;
            }
        }
        if(flag){
            sb.append("31235959");
        }else{
            sb.append("30235959");
        }

        return sb.toString();
    }
}
